﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

using MapCenterSystem.DataInfo;
using MapCenterSystem.Configuration;
using System.Data;

namespace MapCenterSystem.DataAccess
{
    public class AdminDAO
    {
        public int SignIn(AdminDTO admin)
        {
            using (SqlConnection sqlConnect = new SqlConnection(GlobalConfig.ConnectionString))
            {
                SqlCommand command = new SqlCommand();
                command.CommandText = "sp_Admin_SignIn";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = sqlConnect;
                command.CommandTimeout = GlobalConfig.TimeOut;
                command.Parameters.AddWithValue("@account", admin.Account);
                command.Parameters.AddWithValue("@password", admin.Password);
                try
                {
                    sqlConnect.Open();
                }
                catch
                {
                    throw new Exception("Can not connect to database. Please check connect");
                }
                return (int)command.ExecuteScalar();
            }
        }
       
    }
}
